package com.heipi.myjavademo.布隆过滤器;

import org.redisson.Redisson;
import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;

/**
 * @author: honry.guan
 * @create: 2025-08-01 16:02
 **/
public class RedisTest {
    public static void main(String[] args) {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://192.168.9.97:6379");
        RedissonClient redisson = Redisson.create(config);
        RBloomFilter<String> bloomFilter = redisson.getBloomFilter("myfilter");
        bloomFilter.tryInit(100, 0.01);
        bloomFilter.add("Lynn");
        bloomFilter.add("666");
        bloomFilter.add("八股文");
        System.out.println(bloomFilter.contains("Lynn"));
        System.out.println(bloomFilter.contains("张三"));
        redisson.shutdown();
    }

}
